package com.h3c.web.common.utils;

import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;

public class BindingResultUtil {

	public static String assembleErrMsg(BindingResult bindingResult) {
		if (bindingResult.hasErrors()) {
			StringBuffer sb = new StringBuffer();
			for (ObjectError objectError : bindingResult.getAllErrors()) {
				sb.append(",");
				sb.append(objectError.getDefaultMessage());
			}
			return sb.substring(1);
		}
		return null;
	}
}
